package testJdk.commonUse.dateAndCalendar.TestDate;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import org.apache.commons.lang3.time.DateUtils;
import org.junit.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Name : learn_jdk.date.Test04
 * @Description : 描述
 * Created by cyd on 2021-04-22 09:16:32
 */
public class DateFormatStyle {

    @Test
    public void test01() {
        String time = "2021-04-22T09:05:26.028";
        String time2 = time.replace("T", " ");
        System.out.println(time2);
    }

    @Test
    public void test02() {
        String time = "2021-04-22T09:05:26.028";
        String time2 = time.replace("T", " ");
        System.out.println(time2);

        DateTime parse = DateUtil.parse(time2, DatePattern.NORM_DATETIME_MS_PATTERN);
        System.out.println(parse);
    }

    @Test
    public void test03() throws ParseException {
        Date nowTime = new Date();

        SimpleDateFormat format = new SimpleDateFormat("HH:mm");
        String nowTimeStr = format.format(nowTime);

        System.out.println(nowTimeStr);

        nowTime = DateUtils.parseDate(nowTimeStr, "HH:mm");
        long nowHourLong = nowTime.getTime();
    }


}
